<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWxtjUpstream extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //消息发送概况数据（
        Schema::create('wxtj_upstream_msgs', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->tinyInteger('msg_type')->default(0)->comment('消息类型');
            $table->unsignedInteger('msg_user')->default(0)->comment('上行发送了（向公众号发送了）消息的用户数');
            $table->unsignedInteger('msg_count')->default(0)->comment('上行发送了消息的消息总数');
            $table->timestamps();
            $table->index(['ref_date','msg_type',], 'index1');
        });
        //消息分送分时数据
        Schema::create('wxtj_upstream_msghours', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->string('ref_hour', 10)->default('')->comment('数据的小时');
            $table->tinyInteger('msg_type')->default(0)->comment('消息类型');
            $table->unsignedInteger('msg_user')->default(0)->comment('上行发送了（向公众号发送了）消息的用户数');
            $table->unsignedInteger('msg_count')->default(0)->comment('上行发送了消息的消息总数');
            $table->timestamps();
            $table->index(['ref_date','ref_hour','msg_type'], 'index1');
        });
        //获取消息发送周数据
        Schema::create('wxtj_upstream_msgweeks', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->tinyInteger('msg_type')->default(0)->comment('消息类型');
            $table->unsignedInteger('msg_user')->default(0)->comment('上行发送了（向公众号发送了）消息的用户数');
            $table->unsignedInteger('msg_count')->default(0)->comment('上行发送了消息的消息总数');
            $table->timestamps();
            $table->index(['ref_date','msg_type'], 'index1');
        });
        //获取消息发送月数据
        Schema::create('wxtj_upstream_msgmonths', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->tinyInteger('msg_type')->default(0)->comment('消息类型');
            $table->unsignedInteger('msg_user')->default(0)->comment('上行发送了（向公众号发送了）消息的用户数');
            $table->unsignedInteger('msg_count')->default(0)->comment('上行发送了消息的消息总数');
            $table->timestamps();
            $table->index(['ref_date','msg_type'], 'index1');
        });
        //获取消息发送分布数据
        Schema::create('wxtj_upstream_msgdists', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('count_interval')->default(0)->comment('count_interval');
            $table->unsignedInteger('msg_user')->default(0)->comment('上行发送了（向公众号发送了）消息的用户数');
            $table->timestamps();
            $table->index(['ref_date','count_interval'], 'index1');
        });
        //获取消息发送分布周数据
        Schema::create('wxtj_upstream_msgdistweeks', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('count_interval')->default(0)->comment('count_interval');
            $table->unsignedInteger('msg_user')->default(0)->comment('上行发送了（向公众号发送了）消息的用户数');
            $table->timestamps();
            $table->index(['ref_date','count_interval'], 'index1');
        });
        //获取消息发送分布月数据
        Schema::create('wxtj_upstream_msgdistmonths', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('count_interval')->default(0)->comment('count_interval');
            $table->unsignedInteger('msg_user')->default(0)->comment('上行发送了（向公众号发送了）消息的用户数');
            $table->timestamps();
            $table->index(['ref_date','count_interval'], 'index1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::dropIfExists('wxtj_upstream_msgs');
        Schema::dropIfExists('wxtj_upstream_msghours');
        Schema::dropIfExists('wxtj_upstream_msgweeks');
        Schema::dropIfExists('wxtj_upstream_msgmonths');
        Schema::dropIfExists('wxtj_upstream_msgdists');
        Schema::dropIfExists('wxtj_upstream_msgdistweeks');
        Schema::dropIfExists('wxtj_upstream_msgdistmonths');
    }
}
